<!DOCTYPE html>
<!--
  ~  Copyright 2016 http://www.hswebframework.org
  ~
  ~  Licensed under the Apache License, Version 2.0 (the "License");
  ~  you may not use this file except in compliance with the License.
  ~  You may obtain a copy of the License at
  ~
  ~        http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~  Unless required by applicable law or agreed to in writing, software
  ~  distributed under the License is distributed on an "AS IS" BASIS,
  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~  See the License for the specific language governing permissions and
  ~  limitations under the License.
  ~
  ~
  -->

<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv=Content-Type content="text/html;charset=utf-8">
    <title>登录</title>
    <script type="application/javascript" src="//cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>

</head>
<body style="text-align: center">
<button onclick="doOAuth2Login('hsweb-oauth-server')">使用hsweb登录</button>&nbsp;&nbsp;
<button onclick="doOAuth2Login('github')">使用github登录</button>
</body>
</html>
<script type="text/javascript">

    function doOAuth2Login(provider) {
        var uri = getRequest()["redirect"];
        if (!uri) uri = "/";
        window.open('/oauth2/boot/' + provider + '?redirect=' + uri);
    }

    function getRequest() {
        var url = location.search; //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = unescape((strs[i].split("=")[1]));
            }
        }
        return theRequest;
    }

</script>